$('.right-titleicon').on("click", function(e) {
	projectVM.showMenulist()
})
// $("input").blur(function(){
// 	$("body").removeClass("mui-focusin")
// })
document.addEventListener('focusout', function(e) {
	var classList = document.body.classList
	if (classList.contains('mui-focusin')) {
		classList.remove('mui-focusin')
	}
})
projectVM = new Vue({
	el: "#content",
	components: {
		personselect,
		processlog
	},
	data: {
		isSingle: false,
		menuList: [{
			name: '交班',
			path: 'handOver.html'
		}, {
			name: '接班',
			path: 'handOver.html'
		}, {
			name: '列表',
			path: 'index.html'
		}, ],
		approveDes: '',
		changeValue: '',
		checked: [],
		showSubmit: false,
		onStatus: '',
		result: '',
		showMenu: false,
		showMorebtn: false,
		advance: '',
		showAdd: false,
		show_popup: false,
		currentUser: {},
		safetySituation: [],
		equipmentPatrol: [],
		toolsComplete: [],
		logState: [],
		deviceCheckState: [],
		regularWorkState: [],
		hygieneState: [],
		boosterChange: [],
		workId: '',
		filesList:[],
		fileIds: '',
		isEdit: true,
		changeShift: { // 交接班信息
			changeShiftsId: '', //交接班主键
			workId: '', //工作主键
			workDesc: '', //工作描述
			areaCompanyCode: '', //分公司编号
			stationCode: '', //场站编号
			newAreaCode: '', //新能源分公司编号
			newStationCode: '', //新能源场站编号
			offGoingStaffCode: '', //交班人编号
			offGoingStaffName: '', //交班人姓名
			offClassStaffCode: '', //交班组成员编号
			offClassStaffName: '', //交班组成员姓名
			offClassPerson: [], //交办组成员
			offGoingStaffCodeName: '', // 交班人编号加姓名 [xxx]xxx
			onComingStaffCode: '', //接班人编号
			onComingStaffName: '', //接班人姓名
			onComingStaffCodeName: '', // 接班人编号加姓名 [xxx]xxx

			onClassStaffName: '', //接班组成员姓名
			onClassStaffCode: '', //接班组成员编号
			onClassPerson: [], //结伴组成员

			offGoingTime: '', //交班时间
			onComingTime: '', //接班时间
			yesterdayEnergy: '', //昨日上网电量
			aveWindSun: '', //昨日平均风速辐照
			monthEnergy: '', //月累计上网电量
			yearEnergy: '', //年累计上网电量
			allowCount: '', //许可
			backCount: '', //收回
			endCount: '', //终结
			safetyMeasureState: '', //安全措施情况
			boosterStationDevicePatrol: '', //升压站设备巡视
			boosterStationDevicePatrolArr: [], //升压站设备巡视复选框
			boosterStationRunChange: '', //升压站运行方式变化情况
			boosterStationRemarks: '', //升压站备注
			fanInverterRunCount: '', //风机或逆变器运行台数
			fanInverterFaultCount: '', //风机或逆变器故障台数
			fanInverterFaultCode: '', //故障风机或逆变器编号
			usingGroundWireAndAddr: '', //使用中的接地线及装设地点
			defectState: '', //发现的缺陷情况
			remark: '', //备注 
			client: '', //客户ID
			dataSource: 'NEIOS_APP'+localStorage.getItem("currVersion"), //数据来源
			status: '', //业务状态
			dataStatus: '', //是否有效 参见码表0删除&1正常
			createBy: '', //创建人员
			createStaffName: '', //创建人姓名
			createDate: '', //创建时间
			modifyBy: '', //修改人员
			modifyStaffName: '', //修改人员姓名
			modifyDate: '', //修改时间
			reserveField1: '', //扩展字段1
			reserveField2: '', //扩展字段2
			reserveField3: '', //扩展字段3
			reserveField4: '', //扩展字段4
			reserveField5: '', //扩展字段5

			changeShiftInfo: { // 交接班明细
				patrolTime:'',//巡视次数
				changeShiftInfoId: '', // 交接班明细主键,同交接班主键同值
				keyToolBookComplete: '', // 钥匙、工器具、书籍是否齐全
				keyToolBookRemark: '', // 钥匙、工器具、书籍备注
				logState: '', // 运行日志及其它记录完成情况
				logRemark: '', // 运行日志情况备注
				deviceCheckState: '', // 监控、五防系统、通讯、安防设备等检查情况
				deviceCheckRemark: '', // 监控、五防系统、通讯、安防设备等检查情况备注
				regularWorkState: '', // 周期性工作完成情况
				regularWorkRemark: '', // 周期性工作完成情况备注
				hygieneState: '', // 卫生整理情况
				hygieneRemark: '', // 卫生整理情况备注
				elseState: '', // 其他情况说明
				commandtate: '', // 上级指令、指示内容和执行情况
				remark: '', // 备注
				client: '', // 客户ID
				dataSource: 'NEIOS_APP'+localStorage.getItem("currVersion"), // 数据来源
				status: '', // 业务状态
				dataStatus: '', // 是否有效 参见码表0删除&1正常
				createBy: '', // 创建人员
				createStaffName: '', // 创建人姓名
				createDate: '', // 创建时间
				modifyBy: '', // 修改人员
				modifyStaffName: '', // 修改人员姓名
				modifyDate: '', // 修改时间
				reserveField1: '', // 扩展字段1
				reserveField2: '', // 扩展字段2
				reserveField3: '', // 扩展字段3
				reserveField4: '', // 扩展字段4
				reserveField5: '' // 扩展字段5
			}
		},
	},
	created() {
		let data = localStorage.getItem('todoWork') ? JSON.parse(localStorage.getItem('todoWork')) : ''
		
		if (data && data.obj.workId) {
			this.workId = data.obj.workId
			localStorage.setItem('todoWork', '')
		} else {
			this.workId = localStorage.getItem('workId')
		}
		
	},
	mounted() {
		this.currentUser = JSON.parse(localStorage.getItem('neiosUser'))

		// 获取码表接口示例
		let dictCodes =
			'HYGIENE_STATE,REGULAR_WORK_STATE,BOOSTER_CHANGE,SAFETY_SITUATION,EQUIPMENT_PATROL,TOOLS_COMPLETE,LOG_STATE,DEVICE_CHECK_STATE';
		let dict = mui.neiosCommon.queryDict(dictCodes, (data) => {
			if (data != '') {
				// this.TRAINING_SOURCE = data.SAFETY_SITUATION
				// this.NET_SAFE_INFO = data.NET_SAFE_INFO
				// console.log(mui.neiosCommon.dictTransform(data.SAFETY_SITUATION))
				this.boosterChange = data.BOOSTER_CHANGE;
				this.safetySituation = data.SAFETY_SITUATION
				this.equipmentPatrol = data.EQUIPMENT_PATROL
				this.toolsComplete = data.TOOLS_COMPLETE
				this.logState = data.LOG_STATE
				this.deviceCheckState = data.DEVICE_CHECK_STATE
				this.regularWorkState = data.REGULAR_WORK_STATE
				this.hygieneState = data.HYGIENE_STATE
			}
		})
		if (this.workId && this.workId != 'undefined') {
			this.getChangeShiftByWorkId(this.workId, 'workId')
		} else {
			this.getYseterday()
			// 页面显示的编码+姓名(交班人)
			this.$set(this.changeShift, "offGoingStaffCodeName", this.currentUser['userName']);
			// // 传到后台的编码、姓名分开(交班人)
			this.changeShift.offGoingStaffCode = this.currentUser['userId'];
			this.changeShift.offGoingStaffName = this.currentUser['name'];
			// 交班时间
			this.changeShift.offGoingTime = this.getTime(new Date(), "day")
		}
		
	},
	methods: {
		//获取当前时间
							getNowdate() {
								var date = new Date()
								var year = date.getFullYear()
								var month = date.getMonth()
								var day = date.getDate()
								var hour = date.getHours()
								var min = date.getMinutes()
								 var sec = date.getSeconds()
								month = month*1 + 1
								if (month.toString().length < 2) {
									month = '0' + month
								}
								if (day.toString().length < 2) {
									day = '0' + day
								}
								if (hour.toString().length < 2) {
									hour = '0' + hour
								}
								if (min.toString().length < 2) {
									min = '0' + min
								}
								if (sec.toString().length < 2) {
									sec = '0' + sec
								}
								return year + '-' + month + '-' + day + ' ' + hour + ':' + min +':' + sec	
							},
		//获取昨日记录
		getYseterday(){
			setTimeout(function() {
				plus.nativeUI.showWaiting()
			}, 1000);
			var that = this
			var myDate = this.getNowdate()
			let params = {
				date:myDate,
				stationCode:this.currentUser.stationNewCode
			};
			mui.neiosRequst.httpRequst('/app/currentEntry/changeShift/getYesterdayEnergy', params,
				(data) => {
					console.log(JSON.stringify(data))
					if (data.code == '0') {
						console.log(JSON.stringify(data))
						that.changeShift.yesterdayEnergy =data.yesterdayEnergy
						that.changeShift.aveWindSun =data.aveWindSun
						that.changeShift.monthEnergy =data.monthEnergy
						that.changeShift.yearEnergy =data.yearEnergy
					}
					},
					(data)=>{
			
					}
					)
		},
		// 编辑详情回显
		getChangeShiftByWorkId(workId, type) {
			let params = {};
			params[type] = workId
			mui.neiosRequst.httpRequst('/app/currentEntry/changeShift/getChangeShiftByWorkId', params,
				(data) => {
					if (data.code == '0') {
						this.changeShift = data.data.changeShift;
						if (this.currentUser.userId == this.changeShift.offGoingStaffCode && this.changeShift.status == 21) {
							this.isEdit = true
						} else {
							this.isEdit = false
						}
						this.changeShift.offGoingTime = this.getTime(new Date(this.changeShift.offGoingTime), 'day')
						this.$set(this.changeShift, "changeShiftInfo", data.data.changeShiftInfo);
						// 回显接班人
						if (this.changeShift.onComingStaffCode != undefined && this.changeShift.onComingStaffCode != '' && this.changeShift
							.onComingStaffCode != null) {
							this.$set(this.changeShift, "onComingStaffCodeName", '[' + this.changeShift.onComingStaffCode + ']' +
								this.changeShift.onComingStaffName);
							this.$refs.onComing.personids = this.changeShift.onComingStaffCode
							this.$refs.onComing.person = this.changeShift.onComingStaffCodeName
						}
						// 回显交班人
						if (this.changeShift.offGoingStaffCode != undefined && this.changeShift.offGoingStaffCode != '' && this.changeShift
							.offGoingStaffCode != null) {
							this.$set(this.changeShift, "offGoingStaffCodeName", '[' + this.changeShift.offGoingStaffCode + ']' +
								this.changeShift.offGoingStaffName);
						}
						let offClassPerson = []
						if (this.changeShift.offClassStaffCode != undefined && this.changeShift.offClassStaffCode != "" && this.changeShift
							.offClassStaffCode != null) {
							let offClassStaffCodeArr = this.changeShift.offClassStaffCode.split(",")
							for (let index = 0; index < offClassStaffCodeArr.length; index++) {
								const element = offClassStaffCodeArr[index];

								if (index == offClassStaffCodeArr.length - 1) {
									offClassPerson += '[' + element + ']' + this.changeShift.offClassStaffName.split(",")[index];
								} else {
									offClassPerson += '[' + element + ']' + this.changeShift.offClassStaffName.split(",")[index] + ',';
								}
							}
							this.$set(this.changeShift, "offClassPerson", offClassPerson);
							this.$set(this.changeShift, "offClassStaffCode", this.changeShift.offClassStaffCode);
							this.$set(this.changeShift, "offClassStaffName", this.changeShift.offClassStaffName);
						}

						let onClassPerson = []
						if (this.changeShift.onClassStaffCode != undefined && this.changeShift.onClassStaffCode != "" && this.changeShift
							.onClassStaffCode != null) {
							let onClassStaffCodeArr = this.changeShift.onClassStaffCode.split(",")
							for (let index = 0; index < onClassStaffCodeArr.length; index++) {
								const element = onClassStaffCodeArr[index];
								if (index == onClassStaffCodeArr.length - 1) {
									onClassPerson += '[' + element + ']' + this.changeShift.onClassStaffName.split(",")[index];
								} else {
									onClassPerson += '[' + element + ']' + this.changeShift.onClassStaffName.split(",")[index] + ',';
								}
							}
							this.$set(this.changeShift, "onClassPerson", onClassPerson);
							this.$set(this.changeShift, "onClassStaffCode", this.changeShift.onClassStaffCode);
							this.$set(this.changeShift, "onClassStaffName", this.changeShift.onClassStaffName);
						}

						this.$refs.onComingClass.person = this.changeShift.onClassPerson
						this.$refs.onGoingClass.person = this.changeShift.offClassPerson
						this.$refs.onComingClass.personids = this.changeShift.onClassStaffCode
						this.$refs.onGoingClass.personids = this.changeShift.offClassStaffCode
						// 回显复选框内容
						this.$set(this.changeShift, "boosterStationDevicePatrolArr", data.data.changeShift.boosterStationDevicePatrol
							.split(','));
						this.fileIds = data.data.attachIds 
						this.getFileds()
						console.log(JSON.stringify(data))
						// this.attachIds = data.data.attachIds;
						// 流程日志
						// this.getNodeLogByWorkId(this.changeShift.workId);
						//流程图
						// this.getAllNodesByWorkType(enums.WorkType.HANDOVER_WORK);
					} else {
						mui.toast("获取失败：" + data.msg);
					}
				},
				(data) => {
					mui.toast("获取失败：" + data.msg);
				}
			);
		},
		getName(data) {
			console.log(data)
			if (data) {
				let list = []
				data.split(',').map((v) => {
					list.push(v.split(']')[1])
				})
				return list.join(',');
			} else {
				return data
			}

		},
		//获取时间
		getTime(myDate, type) {
			var realYear = myDate.getFullYear();
			var myMonth = myDate.getMonth() + 1;
			var realMonth = myMonth;
			var myDay = myDate.getDate();
			var realDay = myDay;
			var myHour = myDate.getHours();
			var realHours = myHour;
			var myMinute = myDate.getMinutes();
			var realMinute = myMinute;
			var mySecond = myDate.getSeconds();
			var realSecond = mySecond;
			if (myMonth < 10) {
				realMonth = "0" + myMonth;
			}
			if (myDay < 10) {
				realDay = "0" + myDay;
			}
			if (myMinute < 10) {
				realMinute = "0" + myMinute;
			}
			if (myHour < 10) {
				realHours = "0" + myHour;
			}
			if (mySecond < 10) {
				realSecond = "0" + mySecond;
			}
			var realDate = realYear + '-' + realMonth + '-' + realDay + ' ' + realHours + ':' + realMinute + ':' +
				realSecond;
			if (type == "sec") {
				realDate = realYear + '-' + realMonth + '-' + realDay + ' ' + realHours + ':' + realMinute + ':' + realSecond;
			} else if (type == "min") {
				realDate = realYear + '-' + realMonth + '-' + realDay + ' ' + realHours + ':' + realMinute;
			} else if (type == "hour") {
				realDate = realYear + '-' + realMonth + '-' + realDay + ' ' + realHours;
			} else if (type == "day") {
				realDate = realYear + '-' + realMonth + '-' + realDay;
			} else if (type == "month") {
				realDate = realYear + '-' + realMonth;
			} else if (type == "year") {
				realDate = realYear;
			}
			return realDate;
		},
		// 退回
		goBackSubmit() {
			if (this.approveDes) {
				let params = {
					"workId": this.changeShift.workId,
					"workType": '0201', //交接班类型,
					"nodeDealStaffCode": this.currentUser.userId,
					"nodeDealStaffName": this.currentUser.name,
					"approveDes": this.approveDes,
					"nodeDealStaffRole": '0',
					"forwardNode": '0',
					"nodeVisibleRange": '20'
				};
				console.log(params, 'params')
				mui.neiosRequst.httpRequst('/app/currentEntry/changeShift/sendChangeShiftBack', params,
					(data) => {
						if (data.code == '0') {
							mui.toast("退回成功：" + data.msg);
							this.goBack()
						} else {
							mui.toast("退回失败：" + data.msg);
						}
					},
					(data) => {
						mui.toast("退回失败：" + data.msg);
					}
				);
			} else {
				mui.toast("请输入意见描述");
			}

		},
		// 保存
		save(type) {
			// this.changeShiftInfo.offGoingStaffCodeName
			// this.changeShiftInfo.onComingStaffCode
			// this.changeShiftInfo.onComingStaffName
			// this.changeShiftInfo.onComingStaffCodeName
			// console.log(this.$refs.onComing.person)
			// console.log(this.$refs.onComingClass.person)

			// console.log(this.$refs.onGoingClass.personids)
			//复选内容
			this.changeShift.boosterStationDevicePatrol = this.changeShift.boosterStationDevicePatrolArr.join(',');
			// 接班人
			this.changeShift.onComingStaffName = this.getName(this.$refs.onComing.person)
			this.changeShift.onComingStaffCode = this.$refs.onComing.personids
			this.changeShift.onComingStaffCodeName = this.$refs.onComing.person
			//接班组

			this.changeShift.onClassPerson = this.$refs.onComingClass.person
			this.changeShift.onClassStaffName = this.getName(this.$refs.onComingClass.person)
			this.changeShift.onClassStaffCode = this.$refs.onComingClass.personids
			// 交班组
			this.changeShift.offClassPerson = this.$refs.onGoingClass.person
			this.changeShift.offClassStaffName = this.getName(this.$refs.onGoingClass.person)
			this.changeShift.offClassStaffCode = this.$refs.onGoingClass.personids
			this.changeShift.dataSource = 'NEIOS_APP'+localStorage.getItem("currVersion")
			this.changeShift.changeShiftInfo.dataSource = 'NEIOS_APP'+localStorage.getItem("currVersion")
			if(this.changeShift.changeShiftsId == ''){
				this.changeShift.changeShiftsId = mui.neiosCommon.getUuidv4();
			}
			let regu = /^\d{1,12}$|^\d{1,12}[.]\d{1,4}$/;
			let reguSec = /^\d{1,9}$/
			let reSec = new RegExp(reguSec)
			let re = new RegExp(regu);
			if (type == 'submit') {
				if (this.changeShift.patrolTime == '' || this.changeShift.patrolTime == null) {
					mui.toast("请输入巡视次数");
				} else if (!this.changeShift.onComingStaffName) {
					mui.toast("请选择接班人");
				} else if (!this.changeShift.onClassStaffName) {
					mui.toast("请选择接班组");
				} else if (!this.changeShift.offClassStaffName) {
					mui.toast("请选择交班组");
				} else if (!this.changeShift.yesterdayEnergy) {
					mui.toast("请输入昨日上网电量");
				} else if (!this.changeShift.aveWindSun) {
					mui.toast("请输入昨日平均风速/辐照");
				} else if (!this.changeShift.monthEnergy) {
					mui.toast("请输入月累计上网电量");
				} else if (!this.changeShift.yearEnergy) {
					mui.toast("请输入年累计上网电量");
				} else if (!this.changeShift.allowCount) {
					mui.toast("请输入许可");
				} else if (!this.changeShift.backCount) {
					mui.toast("请输入收回");
				} else if (!this.changeShift.endCount) {
					mui.toast("请输入终结");
				}  else if (!this.changeShift.fanInverterRunCount) {
					mui.toast("选输入风机或逆变器运行台数");
				} else if (!this.changeShift.fanInverterFaultCount) {
					mui.toast("选输入风机或逆变器故障台数");
				} else if (!this.changeShift.usingGroundWireAndAddr) {
					mui.toast("选输入使用中的接地线及装设地点");
				} else if (!this.changeShift.changeShiftInfo.commandtate) {
					mui.toast("选输入上级指令、指示内容和执行情况");
				} else {
					if (!regu.test(this.changeShift.yesterdayEnergy)) {
						mui.toast("昨日上网电量请输入正数且整数位最多12位小数位最多4位");
					} else if (!regu.test(this.changeShift.aveWindSun)) {
						mui.toast("昨日平均风速/辐照请输入正数且整数位最多12位小数位最多4位");
					} else if (!regu.test(this.changeShift.monthEnergy)) {
						mui.toast("月累计上网电量请输入正数且整数位最多12位小数位最多4位");
					} else if (!regu.test(this.changeShift.yearEnergy)) {
						mui.toast("昨日上网电量请输入正数且整数位最多12位小数位最多4位");
					} else if (!reguSec.test(this.changeShift.allowCount)) {
						mui.toast("许可请输入正数且整数位最多9位");
					} else if (!reguSec.test(this.changeShift.backCount)) {
						mui.toast("收回请输入正数且整数位最多9位");
					} else if (!reguSec.test(this.changeShift.endCount)) {
						mui.toast("终结请输入正数且整数位最多9位");
					} else if (!reguSec.test(this.changeShift.fanInverterRunCount)) {
						mui.toast("运行台数请输入正数且整数位最多9位");
					} else if (!reguSec.test(this.changeShift.fanInverterFaultCount)) {
						mui.toast("故障台数请输入正数且整数位最多9位");
					} 
					else if (this.changeShift.safetyMeasureState == '') {
						mui.toast("请选择执行中的工作票工作现场的安全措施情况");
					}
					else if (this.changeShift.boosterStationRunChange == '') {
						mui.toast("请选择升压站运行方式变化情况");
					}
					else if (this.changeShift.changeShiftInfo.keyToolBookComplete == '') {
						mui.toast("请选择钥匙,工器具,书籍是否齐全");
					}
					else if (this.changeShift.safetyMeasureState == '') {
						mui.toast("请选择升压站运行方式变化情况");
					}
					else if (this.changeShift.changeShiftInfo.logState == '') {
						mui.toast("请选择运行日志及其它记录完成情况");
					}
					else if (this.changeShift.changeShiftInfo.deviceCheckState == '') {
						mui.toast("请选择监控、五防系统、通讯、安防设备等检查情况");
					}
					else if (this.changeShift.changeShiftInfo.regularWorkState == '') {
						mui.toast("请选择周期性工作完成情况");
					}
					else if (this.changeShift.changeShiftInfo.hygieneState == '') {
						mui.toast("请选择卫生整理情况");
					}
					else {
						// 保存 21  提交32
						this.changeShift.status = 32
						// 提交
						let param = {
							saveOrSubmit: type,
							currentUser: this.currentUser,
							changeShift: this.changeShift,
							changeShiftInfo: this.changeShift.changeShiftInfo,
							fileIds: this.fileIds,
						};
						// 获取列表
						mui.neiosRequst.httpRequst('/app/currentEntry/changeShift/saveOrUpdateChangeShift', param,
							(data) => {
								if (data.code == '0') {
									mui.toast("提交成功");
									this.goBack()
								} else {
									mui.toast("提交失败：" + data.msg);
								}
							},
							(data) => {
								mui.toast("提交失败：" + data.msg);
							}
						);
					}

				}
			} else if (type == 'save') {
				if (this.changeShift.yesterdayEnergy && !regu.test(this.changeShift.yesterdayEnergy)) {
					mui.toast("昨日上网电量请输入正数且整数位最多12位小数位最多4位");
				} else if (this.changeShift.aveWindSun && !regu.test(this.changeShift.aveWindSun)) {
					mui.toast("昨日平均风速/辐照请输入正数且整数位最多12位小数位最多4位");
				} else if (this.changeShift.monthEnergy && !regu.test(this.changeShift.monthEnergy)) {
					mui.toast("月累计上网电量请输入正数且整数位最多12位小数位最多4位");
				} else if (this.changeShift.yearEnergy && !regu.test(this.changeShift.yearEnergy)) {
					mui.toast("昨日上网电量请输入正数且整数位最多12位小数位最多4位");
				} else if (this.changeShift.allowCount && !reguSec.test(this.changeShift.allowCount)) {
					mui.toast("许可请输入正数且整数位最多9位");
				} else if (this.changeShift.backCount && !reguSec.test(this.changeShift.backCount)) {
					mui.toast("收回请输入正数且整数位最多9位");
				} else if (this.changeShift.endCount && !reguSec.test(this.changeShift.endCount)) {
					mui.toast("终结请输入正数且整数位最多9位");
				} else if (this.changeShift.fanInverterRunCount && !reguSec.test(this.changeShift.fanInverterRunCount)) {
					mui.toast("运行台数请输入正数且整数位最多9位");
				} else if (this.changeShift.fanInverterFaultCount && !reguSec.test(this.changeShift.fanInverterFaultCount)) {
					mui.toast("故障台数请输入正数且整数位最多9位");
				} else {
					// 保存 21  提交32
					this.changeShift.status = 21
					// 提交
					let param = {
						saveOrSubmit: type,
						currentUser: this.currentUser,
						changeShift: this.changeShift,
						changeShiftInfo: this.changeShift.changeShiftInfo,
						fileIds: this.fileIds,
					};
					console.log(JSON.stringify(param),'==================')
					//获取列表
					mui.neiosRequst.httpRequst('/app/currentEntry/changeShift/saveOrUpdateChangeShift', param,
						(data) => {
							if (data.code == '0') {
								mui.toast("保存成功");
								this.goBack()
							} else {
								mui.toast("保存失败：" + data.msg);
							}
						},
						(data) => {
							mui.toast("保存失败：" + data.msg);
						}
					);
				}
			} else {
				// 保存 21  提交32
				// this.changeShift.status = 21
				// 提交
				let param = {
					saveOrSubmit: type,
					currentUser: this.currentUser,
					changeShift: this.changeShift,
					changeShiftInfo: this.changeShift.changeShiftInfo,
					fileIds: this.fileIds,
				};
				console.log(this.changeShift)
				//获取列表
				mui.neiosRequst.httpRequst('/app/currentEntry/changeShift/saveOrUpdateChangeShift', param,
					(data) => {
						if (data.code == '0') {
							mui.toast("接班成功");
							this.goBack()
						} else {
							mui.toast("接班失败" + data.msg);
						}
					},
					(data) => {
						mui.toast("接班失败：" + data.msg);
					}
				);
			}



		},
		//返回上一页
		goBack() {
			let page1 = plus.webview.getWebviewById("dailyRecord/shiftsChange/index.html");
			let page2 = plus.webview.getWebviewById("../sitOperation/terminalwork/terminalwork.html");
			let param = {}
			param.isRefresh = true
			mui.fire(page1, 'param', param);
			mui.fire(page2, 'isRefresh', param);
			mui.back()
		},
		//更多按钮
		showMore() {
			this.showMorebtn ? this.showMorebtn = false : this.showMorebtn = true
		},
		//阻止事件冒泡
		clickStop() {

		},
		//选择是否为值班人
		checkOnstatus() {
			console.log(this.onStatus)
			this.onStatus ? this.onStatus = false : this.onStatus = true

		},
		//点击菜单
		menuClick(e) {
			this.showMenu = false
			if (e.name == '交班') {
				this.navTo(e.path)
				location.reload();
			} else if (e.name == '接班') {
				let param = {
					"workType": "0201",
					"userId": this.currentUser.userId
				}
				//获取列表
				mui.neiosRequst.httpRequst('/app/currentEntry/changeShift/loadToDoByWorkType', param,
					(data) => {
						if (data.code == '0') {
							if (data.data.length > 0) {
								this.navTo(e.path, data.data[0].workId)
								location.reload();
							} else {
								mui.toast("暂无数据");
							}

						} else {
							mui.toast("获取数据失败：" + data.msg);
						}
					},
					(data) => {
						mui.toast("获取数据失败：" + data.msg);
					}
				);
			} else {
				this.navTo(e.path)
			}

		},
		// 上傳
		upload() {
			let that = this
			mui.neiosCommon.doUploads(function(ret) {
				if ("0" == ret.code) {
					console.log("成功：" + JSON.stringify(ret))
					// mui.toast('文件'+ret.data.fileName+"上传成功");
					that.fileIds == "" ? that.fileIds += ret.data.fileId : that.fileIds += "," + ret.data.fileId;
					that.getFileds()
				} else {
					mui.toast('文件上传失败');
				}
			}, function(err) {
				mui.toast('文件上传失败');
			})
		},
		// 删除文件
		delDown(data){
			let myFileIds = this.fileIds.split(',')
			myFileIds.splice(myFileIds.findIndex(item => item.fileId===data.fileId),1)
			this.fileIds = myFileIds.join(',')
			console.log(this.fileIds)
			this.getFileds()
		},
		// 获取文件列表
		getFileds(){
			mui.neiosRequst.httpRequst('/app/common/getFileList', {fileIds:this.fileIds},
				(data) => {
					if (data.code == '0') {
						console.log(JSON.stringify(data.data))
						this.filesList = data.data
					} else {
						mui.toast("获取失败：" + data.msg);
					}
				},
				(data) => {
					mui.toast("退回失败：" + data.msg);
				}
			);
		},
		// 下载
		downLoad(data) {
			let url = "/app/common/downloadFile";
			let param = {};
			param.fileId = data.fileId;
			mui.neiosCommon.downLoadFile(param, function(ret) {
				mui.plusReady(function() {
					plus.nativeUI.closeWaiting();
				})
				//调用存储
				var callbackID = plus.bridge.callbackId(function(ret) {
					mui.toast(ret[0])
				}, function(err) {
					mui.toast('文件下载失败')
				});
				plus.bridge.execSync("FileHelper", "doFileSave", [callbackID, ret, data.fileName, "Argus3", "Argus4"])
			}, function(err) {
				mui.plusReady(function() {
					plus.nativeUI.closeWaiting();
				})
				mui.toast('文件下载失败')
			});
		},
		//左上角菜单显示隐藏
		showMenulist() {
			this.showMenu ? this.showMenu = false : this.showMenu = true
		},
		navTo(e, data) {
			localStorage.setItem("workId", data);
			mui.openWindow({
				url: e,
				id: e,
				extras: {},
				waiting: {
					autoShow: false
				}
			});
		},
	},

})
